package com.mjlf.hometeach.common.db.address;

import com.mjlf.hometeach.common.db.provider.address.DistrictProvider;
import com.mjlf.hometeach.common.entity.address.District;
import org.apache.ibatis.annotations.*;

import java.util.List;

/**
 * @auther a123
 * @create 2018-05-03 23:04
 * @desc
 */
@Mapper
public interface DistrictDao {

    /**
     * 添加一个地区信息到数据库
     * @param district
     * @return
     */
    @InsertProvider(type = DistrictProvider.class, method = "save")
    @Options(useGeneratedKeys = true, keyProperty = "id", keyColumn = "id")
    int save(District district);

    /**
     * 根据id删除指定地区信息
     * @param id
     * @return
     */
    @DeleteProvider(type = DistrictProvider.class, method = "deleteById")
    int deleteById(Integer id);

    /**
     * 根据distric 中id为判断条件，更新distric中属性不为null对应字段信息
     * @param district
     * @return
     */
    @UpdateProvider(type = DistrictProvider.class, method = "updateById")
    int updateConditionById(District district);

    /**
     * 根据id查找指定地区信息
     * @param id
     * @return
     */
    @SelectProvider(type = DistrictProvider.class, method = "getDistricById")
    District getDistrictById(Integer id);

    /**
     * 根据distric中属性不为null对应字段为判断条件查询地区信息集合
     * @param district
     * @return
     */
    @SelectProvider(type = DistrictProvider.class, method = "listByCondition")
    List<District> listDistrictByCondition(District district);
}
